/****************************************************************************
 * stri_common
 * creat : 20200830
 * modify: none
 * **************************************************************************/
#include "stri.h"
#include "stri_simulink.h"

stri_type stri;

/*****************************************************************************
* @brief   mj stri_control, called frome step-idle
* @param   none
* @return  none
*****************************************************************************/
void stri_config(void)
{
	/*----------------------------------------------------------------------*/
	// 灭菌参数
	stri.stri.temp = 1210;
	stri.stri.time = 5;
	
	/*----------------------------------------------------------------------*/
	// 控制温度
	stri.temp.ft = 1000;								// 沸点温度
	stri.temp.air_out = stri.temp.ft + 150;				// 排气温度
	stri.temp.open = 800;								// 开门温度
	stri.temp.offset = 3;								// 偏置温度
	stri.temp.max = 1380;								// 气温最大值
	stri.temp.above = 25;								// 允许控制超温
	
	/*----------------------------------------------------------------------*/
	//杂项配置
	stri.cfg.airout_level = stri_hal.airout_level_max;	// 排气等级
	stri.cfg.f0_sel = STRI_F0_SEL_AIR;					// f0计算温度选择-气温
	
	/*----------------------------------------------------------------------*/
	// 饱和自检
	stri.press_dual.mode = STRI_PRESS_DUAL_SATURATED;	// 饱和自检	
	stri.press_dual.sv = 5;								// 压力自检次数
	stri.press_dual.press_offset = 50;					// 压力偏差
	if(stri.press_dual.mode == STRI_PRESS_DUAL_SATURATED)
	{
		// 检测温度点
		stri.press_dual.temp = 1070;		
	}
	else if(stri.press_dual.mode == STRI_PRESS_DUAL_PULSE)
	{
		// 压力脉冲
		stri.press_dual.temp = stri.temp.ft + 70; 
	}
	
	/*----------------------------------------------------------------------*/
	// 正压 - 真空
	stri.pressurize.check_en = 0;
	stri.pressurize.buchang_en = 0;
	stri.pressurize.buchang_press = 0;
	stri.pressurize.buchang_offset = 0;
	stri.cfg.vacuum_check_en = 0;
	stri.cfg.vacuum_fore_en = 0;
	
	/*----------------------------------------------------------------------*/
	// 斜率升压、冷却
	stri.cfg.kl_en = 0;						// 开启后自动关闭排气功能
	stri.cfg.kl_up = 210.0f / (21*60-30);	// C/S
	stri.cfg.kl_dn = 210.0f / (41*60-30);	// C/S
	
	/*----------------------------------------------------------------------*/
	// 程序模式
	stri.prog.mode = 0;
	stri.prog.seg_max = 0;
	stri.prog.tab = 0;
	stri.prog.seg_cnt = 0;
	
	/*----------------------------------------------------------------------*/
	// 预热-预约
	stri.temp.order = 800;				//预热温度
	stri.cfg.order_en = 0;				//预热功能
	stri.cfg.order_time_dly = 0;		//预约时间，0无预约
	stri.cfg.order_time_rtc.val = 0;	//预约RTC
	
	/*----------------------------------------------------------------------*/
	// 加热延时
	stri.cfg.heat_delay_time = 30;		// 秒
	
	/*----------------------------------------------------------------------*/
	// 干燥功能
	stri.dry.temp = 1200;
	stri.dry.time = 60;
	// 模式 0进气 1真空
	stri.dry.mode = STRI_DRY_MODE_NONE;	
	
	
	/*----------------------------------------------------------------------*/
	// 保温功能
	stri.warm.temp = 600;
	stri.warm.time = 24*60;
	// 模式 0内加热 1外加热
	stri.warm.mode = STRI_WARM_MODE_NONE;
	
	/*----------------------------------------------------------------------*/
	// 安全阀测试
	stri.cfg.b_safe_tst = 0;
	
	/*----------------------------------------------------------------------*/
	// 排水方式
	stri.wat_out.mode = STRI_WATO_MODE_STEAM;	//0-蒸汽压力 1-正压进气排水
	stri.wat_out.req = 0;	// 结束自动排水功能
	if(stri.wat_out.mode == STRI_WATO_MODE_STEAM)
		stri.wat_out.temp = stri.temp.ft + 70;
	else
		stri.wat_out.temp = stri.temp.ft;	
	
	stri.wat_out.time =  120;
	
	/*----------------------------------------------------------------------*/
	// 加热
	stri.heat.ext_main_offset = -100;
	stri.heat.ext_max = 1000;
	stri.heat.main_max = 1000;
}

/*****************************************************************************
* @brief   stri_fun_list_type 执行列表
* @param   none
* @return  none
*****************************************************************************/
char stri_exe_idle(void);
char stri_exe_checkself(void);
char stri_exe_order_time(void);
char stri_exe_order_heat(void);
char stri_exe_pressurize(void);
char stri_exe_vacuum(void);
char stri_exe_fore_vacuum(void);
char stri_exe_pre_heat(void);
char stri_exe_heat(void);
char stri_exe_heat_delay(void);
char stri_exe_press_dual(void);
char stri_exe_press_up(void);
char stri_exe_press_keep(void);
char stri_exe_auto_cool(void);
char stri_exe_air_out(void);
char stri_exe_wat_out(void);
char stri_exe_dry(void);
char stri_exe_warm(void);
char stri_exe_comp_cool(void);
char stri_exe_comp(void);
char stri_exe_end(void);

const stri_fun_list_type stri_fun =
{
	{STRI_FUN_ORR, stri_exe_idle},
	{STRI_FUN_ORR, stri_exe_checkself},
	{STRI_FUN_ORR, stri_exe_order_time},
	{STRI_FUN_ORR, stri_exe_order_heat},
	{STRI_FUN_ORR, stri_exe_pressurize},
	{STRI_FUN_ORR, stri_exe_vacuum},
	{STRI_FUN_ORR, stri_exe_fore_vacuum},
	{STRI_FUN_ORR, stri_exe_pre_heat},
	{STRI_FUN_ORR, stri_exe_heat},
	{STRI_FUN_ORR, stri_exe_heat_delay},
	{STRI_FUN_ORR, stri_exe_press_dual},
	{STRI_FUN_ORR, stri_exe_press_up},
	{STRI_FUN_ORR, stri_exe_press_keep},
	{STRI_FUN_ORR, stri_exe_auto_cool},
	{STRI_FUN_ORR, stri_exe_air_out},
	{STRI_FUN_ORR, stri_exe_wat_out},
	{STRI_FUN_ORR, stri_exe_dry},
	{STRI_FUN_ORR, stri_exe_warm},
	{STRI_FUN_ORR, stri_exe_comp_cool},
	{STRI_FUN_ORR, stri_exe_comp},
	{STRI_FUN_ORR, stri_exe_end},
};


